<html>

<head>
<meta http-equiv="Content-Language" content="en-us">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Block</title>
</head>

<body>
<?php
include("../connection/connection.php");
include("reportFunctions.php");
$distId=$_REQUEST['distId'];
$sqlReport = "SELECT `district_id`,`district_name`,`block_id`,`block_name` FROM `tbl_lookup_location` where `district_id` = ".$distId." group by `block_id`";
$queryReport = mysql_query($sqlReport);

?>

<table border="0" width="728" cellspacing="0" cellpadding="0">
	<tr>
		<td width="1039" height="26" bgcolor="#E9E9E9">
		<p align="center"><span style="font-size: 9pt; font-weight: 700">
	  <font face="Verdana" color="#224568">Block wise scheme wise tanker water supply in district</font></span></td>
	</tr>
	
	<tr>
		<td bgcolor="#E9E9E9" height="56">
		<table border="1" width="728" cellspacing="0" cellpadding="0" height="47" bgcolor="#C5D8EB">
			<tr>
				<td width="43" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>Sr. No.</b></font></td>
				<td width="121" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>Name of the 
				Block</b></font></td>
				<td width="98" align="center">
				<p align="center"><font face="Verdana" style="font-size: 8.5pt">
			  <b>Type of Scheme</b></font></td>
				<td width="102" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Population covered as of 2010</b></font></td>
				<td width="109" align="center">
				<font style="font-size: 8.5pt" face="Verdana"><b>Total tanker trips/day (No./day)</b></font></td>
				<td width="124" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Quantity of water 
				supplied (KLD)</b></font></td>
				<td width="115" align="center">
				<font face="Verdana" style="font-size: 8.5pt"><b>Per capita tanker 
				water supply (lpcd)</b></font></td>
			</tr>
		</table>		</td>
	</tr>
	<tr>
		<td>
		<table border="1" width="728" cellspacing="0" cellpadding="0" height="49" bordercolor="#C5D8EB" style="border: 1px solid #BBD1E8" bgcolor="#F9F9F9">
		<?php
			
			$slNo = 1;
			$totalTanker=0;
			$totalPopulation = 0;
			$totalPopPerScheme = 0;	
			$totalPerCapta=0;								
			while($rowReport = mysql_fetch_array($queryReport)) {
			?>
			<tr>
				<td width="42" rowspan="5" align="center" valign="top"><font style="font-size: 8.5pt" face="Verdana"><?php echo $slNo; ?></font></td>
				<td width="123" rowspan="5" align="center" valign="top"><font style="font-size: 8.5pt" face="Verdana"><?php echo $rowReport['block_name']; ?></font></td>
				<td align="center" width="96"><font style="font-size: 8.5pt" face="Verdana">P &amp; T</font></td>
				<td align="center" width="103"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numPopulationPnT=getPopulationTankerBlockWise($distId,'P&T',$rowReport['block_id'])+getPopulationTankerBlockWise($distId,'TSS(P&T)',$rowReport['block_id']);
				if($numPopulationPnT=='')
				{
					echo $numPopulationPnT=0;
				}
				else
				{
					echo $numPopulationPnT;
				}
				
				 ?></font></td>
				<td align="center" width="108"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numTankerPnT=getTankerNoBlockWise($distId,'P&T',$rowReport['block_id'])+getTankerNoBlockWise($distId,'TSS(P&T)',$rowReport['block_id']); 
				if($numTankerPnT=='')
				{
				echo $numTankerPnT=0;
				}
				else
				{
					echo $numTankerPnT;
				}
				?></font></td>
				<td align="center" width="126"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numWaterQtyPnT=getWaterQtyBlockWise($distId,'P&T',$rowReport['block_id'])+getWaterQtyBlockWise($distId,'TSS(P&T)',$rowReport['block_id']);
				if($numWaterQtyPnT=='')
				{
				echo $numWaterQtyPnT=0;
				}
				else
				{
					echo $numWaterQtyPnT;
				}
				?></font></td>
				<td align="center" width="114"><font style="font-size: 8.5pt" face="Verdana">
				  <?php 
				//$a=getPopulationTankerBlockWise($distId,'P&T',$rowReport['block_id']);
				if($numPopulationPnT==0){
				echo $numPerCaptaPnT="0.00";
				}else{
				echo $numPerCaptaPnT=number_format(($numWaterQtyPnT/$numPopulationPnT)*1000,2,'.','');} ?>
				</font></td>
			</tr>
			<tr>
				<td align="center" width="96"><font style="font-size: 8.5pt" face="Verdana">Piped</font></td>
				<td align="center" width="103"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numPopulationPiped=getPopulationTankerBlockWise($distId,'piped',$rowReport['block_id']); 
				if($numPopulationPiped=='')
				{
					echo $numPopulationPiped=0;
				}
				else
				{
					echo $numPopulationPiped;
				}
				?></font></td>
				<td align="center" width="108"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numTankerPiped=getTankerNoBlockWise($distId,'piped',$rowReport['block_id']);
				if($numTankerPiped=='')
				{
				echo $numTankerPiped=0;
				}
				else
				{
					echo $numTankerPiped;
				}
				?></font></td>
				<td align="center" width="126"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numWaterQtyPiped=getWaterQtyBlockWise($distId,'piped',$rowReport['block_id']);
				if($numWaterQtyPiped=='')
				{
				echo $numWaterQtyPiped=0;
				}
				else
				{
					echo $numWaterQtyPiped;
				}
				?></font></td>
				<td align="center" width="114"><font style="font-size: 8.5pt" face="Verdana"><?php
				$a=getPopulationTankerBlockWise($distId,'Piped',$rowReport['block_id']);
				if($a==0){
				echo $numPerCaptaPiped="0.00";
				}else{
				 echo $numPerCaptaPiped=number_format((getWaterQtyBlockWise($distId,'piped',$rowReport['block_id'])/getPopulationTankerBlockWise($distId,'Piped',$rowReport['block_id']))*1000,2,'.',''); }?></font></td>
			</tr>
			<tr>
				<td align="center" width="96"><font style="font-size: 8.5pt" face="Verdana">Sanitary Diggs</font></td>
				<td align="center" width="103"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numPopulationSanDigg=getPopulationTankerBlockWise($distId,'Sanitary Diggs',$rowReport['block_id']);
				if($numPopulationSanDigg=='')
				{
					echo $numPopulationSanDigg=0;
				}
				else
				{
					echo $numPopulationSanDigg;
				}
				?></font></td>
				<td align="center" width="108"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numTankerSanDigg=getTankerNoBlockWise($distId,'Sanitary Diggs',$rowReport['block_id']);
				if($numTankerSanDigg=='')
				{
				echo $numTankerSanDigg=0;
				}
				else
				{
					echo $numTankerSanDigg;
				}
				?></font></td>
				<td align="center" width="126"><font style="font-size: 8.5pt" face="Verdana">
				  <?php 
				$numWaterQtySanDigg=getWaterQtyBlockWise($distId,'Sanitary Diggs',$rowReport['block_id']);
				if($numWaterQtySanDigg=='')
				{
				echo $numWaterQtySanDigg=0;
				}
				else
				{
					echo $numWaterQtySanDigg;
				}
				?>
				</font></td>
				<td align="center" width="114"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$a=getPopulationTankerBlockWise($distId,'Sanitary Diggs',$rowReport['block_id']);
				if($a==0){
				echo $numPerCaptaSanDigg="0.00";
				}else{
				 echo $numPerCaptaSanDigg=number_format((getWaterQtyBlockWise($distId,'Sanitary Diggs',$rowReport['block_id'])/getPopulationTankerBlockWise($distId,'Sanitary Diggs',$rowReport['block_id']))*1000,2,'.',''); } ?></font></td>
			</tr>
			<tr>
				<td align="center" width="96"><font style="font-size: 8.5pt" face="Verdana">HP</font></td>
				<td align="center" width="103"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numPopulationHp=getPopulationTankerBlockWise($distId,'HP',$rowReport['block_id']);
				if($numPopulationHp=='')
				{
					echo $numPopulationHp=0;
				}
				else
				{
					echo $numPopulationHp;
				}
				?></font></td>
				<td align="center" width="108"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numTankerHp=getTankerNoBlockWise($distId,'HP',$rowReport['block_id']);
				if($numTankerHp=='')
				{
				echo $numTankerHp=0;
				}
				else
				{
					echo $numTankerHp;
				}
				?></font></td>
				<td align="center" width="126"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$numWaterQtyHp=getWaterQtyBlockWise($distId,'HP',$rowReport['block_id']);
				if($numWaterQtyHp=='')
				{
				echo $numWaterQtyHp=0;
				}
				else
				{
					echo $numWaterQtyHp;
				}
				?></font></td>
				<td align="center" width="114"><font style="font-size: 8.5pt" face="Verdana"><?php 
				$a=getPopulationTankerBlockWise($distId,'HP',$rowReport['block_id']);
				if($a==0){
				echo $numPerCaptaHp="0.00";
				}else{
				echo $numPerCaptaHp=number_format((getWaterQtyBlockWise($distId,'HP',$rowReport['block_id'])/getPopulationTankerBlockWise($distId,'HP',$rowReport['block_id']))*1000,2,'.',''); }?></font></td>
			</tr>
			<tr>
			<?php 
			$totalTanker=$numTankerPnT + $numTankerPiped + $numTankerHp + $numTankerSanDigg;// +$numTankerRwss
			$totalPopulation = $numPopulationHp + $numPopulationPiped + $numPopulationPnT + $numPopulationSanDigg;// +$numSchemeRwss;
			$totalWaterQty=$numWaterQtyPnT + $numWaterQtyPiped + $numWaterQtyHp + $numWaterQtySanDigg;//$numWaterQtyRwss
			$totalPerCapta=$numPerCaptaPnT + $numPerCaptaPiped + $numPerCaptaHp;//$numPerCaptarwss
			$grandTotalTanker+=$totalTanker;
			$grandTotalPop+=$totalPopulation;
			$grandWaterQty+=$totalWaterQty;
			$grandPerCapta+=$totalPerCapta;
			?>
				<td align="center" width="96" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b>Total</b></font></td>
				<td align="center" width="103" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $totalPopulation; ?></b></font></td>
				<td align="center" width="108" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $totalTanker;?></b></font></td>
				<td align="center" width="126" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $totalWaterQty;?></b></font></td>
				<td align="center" width="114" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php
				if($totalPopulation==0)
				{
					echo "0.00";
				}
				else
				{
					echo $numPerCaptatotal=number_format(($totalWaterQty/$totalPopulation)*1000,2,'.','');
				}
				?></b></font></td>
			</tr>
			<?php 
			$slNo++;
			} ?>
			<tr>
			<td align="center" bgcolor="#E9E9E9" colspan="3">
				<font style="font-size: 8.5pt" face="Verdana"><b>Grand Total</b></font></td>
				<td align="center" width="103" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $grandTotalPop;?></b></font></td>
				<td align="center" width="108" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $grandTotalTanker;?></b></font></td>
				<td align="center" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php echo $grandWaterQty;?></b></font></td>
				<td align="center" width="114" bgcolor="#E9E9E9"><font style="font-size: 8.5pt" face="Verdana"><b><?php
				if($grandTotalPop==0)
				{
					echo "0.00";
				}
				else
				{
					echo $numPerCaptaGrand=number_format(($grandWaterQty/$grandTotalPop)*1000,2,'.','');
				}
				
				?></b></font></td>
			</tr>
		</table>		</td>
	</tr>
</table>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>



</body>

</html>